// pages/asc/facultyDetail/facultyDetail.js
var _utils = require('../../../utils/utils.js')
var _http = require('../../../utils/httpUtils.js')
Page({

    /**
     * 页面的初始数据
     */
    data: {
        teacherId: 1, // 导师id
        pageNum: 1,//课程列表页码
        //课程列表
        classList: [
            // {
            //     "id": 1,
            //     "img": '/images/common/img11-1.png',
            //     "title": "History of Columbia University Korean historiography",
            //     "time": "2019.10.10-2019.11.20"
            // }, {
            //     "id": 2,
            //     "img": '/images/common/img11-1.png',
            //     "title": "History of Columbia University Korean historiography",
            //     "time": "2019.10.10-2020.11.20"
            // }, {
            //     "id": 3,
            //     "img": '/images/common/img11-1.png',
            //     "title": "History of Columbia University Korean historiography",
            //     "time": "2020.10.10-2021.11.20"
            // }, {
            //     "id": 4,
            //     "img": '/images/common/img11-1.png',
            //     "title": "History of Columbia University Korean historiography",
            //     "time": "2008.10.10-2019.11.20"
            // }, {
            //     "id": 5,
            //     "img": '/images/common/img11-1.png',
            //     "title": "History of Columbia University Korean historiography",
            //     "time": "2018.10.10-2029.11.20"
            // }
        ],
        faculty: {
            "img": '/images/common/img11.png',
            "name": 'William Kirby',
            "school": 'Harvard Business School',
            "honor": 'Distinguished Tenured Professor',
            "honor2": "Distinguished Tenured Professor 40 of the world's most outstanding professors under 40 ", "business": "Chaired Professor of Business",
            "detail": "Member of the Editorial Board of the Asset Pricing Research Review. He teaches MBA at Harvard Business School and manages education Courses, Ph.D. courses and special customs courses. His award-winning research has been published in Caijing's top journalson. In The Wall Street Journal, The New York Times, The Washington Post, The Economics Magazine, and Forbes It is also often mentioned in various media.He was named the 2008 Academic Frontier of “Keep up and Invest” by Poets & Quants Awards, 2017 40 under 40 business school professors, and top teachers at CNBC Harvard University."
        },
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let id = options.id;
        console.log(id);
        // id = 1;
        this.setData({
            teacherId: id
        })
        //加载老师信息
        getTeacherInfo(this);
        //加载课程列表
        getClassList(this);
    },
    goClassDetai: function (e) {
        let classId = e.currentTarget.dataset.id;
        wx.navigateTo({
            url: '../kechenginfo/kechenginfo?id=' + classId,
            success: function (res) { },
            fail: function (res) { },
            complete: function (res) { },
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        this.setData({
            pageNum: this.data.pageNum + 1
        })
        getClassList(this);
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})

function getTeacherInfo(_this) {

    _http.post(_http.tutorInfo, { id: _this.data.teacherId}, function (res) {
        _this.setData({
            faculty: res.data.tutor
        })
    })
}

function getClassList(_this) {
    _http.post(_http.tutorClass, { id: _this.data.teacherId, page: _this.data.pageNum, list_row: 10 }, function (res) {
        _this.setData({
            classList: res.data.list.concat(_this.data.classList)
        })
    })
}